package com.ikun.mybatisstudy.controller;

import com.ikun.mybatisstudy.common.Result;
import com.ikun.mybatisstudy.dto.User;
import com.ikun.mybatisstudy.services.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Classname UserController
 * @Description TODO
 * @Date 2025/3/20 10:05
 * @Created by Song zuo gang
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    UserService userService;

    @PostMapping("/queryById")
    public Result<User> queryById(@RequestBody User user){
        User user1 = userService.queryById(user.getId());
        return Result.ok(user1);
    }

    @PostMapping("/insert")
    public Result<User> insert(@RequestBody User user){
        boolean result = userService.insert(user);
        return Result.ok(result);
    }

    @PostMapping("/update")
    public Result<Boolean> update(@RequestBody User user){
        boolean result = userService.updateUser(user);
        return Result.ok(result);
    }


}
